package 种花605;

import com.sun.management.jmx.JMProperties;

/**
 * ToDo
 *
 * @author: liuzhixin
 * @date: 2021/5/6,23:03
 * @project_name:LeetCode
 */
public class AA {
    //     1                      1   1
    // 1 0 0 0 1      0 1 0 0   0 0 0 0
    //                     0 1 2 3
    public static boolean canPlaceFlowers(int[] flowerbed, int n) {
        int num = 0,c = 1;
        for (int i=0;i<flowerbed.length;i++){
            if (flowerbed[i] == 0){
                c++;
            }else{
                c = 0;
            }
            if (c == 3){
                num++;
                c = 1;
            }
        }
        if (c == 2){
            num++;
        }
        return n <= num;
    }

    public static void main(String[] args) {
        int[] test = {1,0,0,0,1};
        int n = 2;
        boolean b = canPlaceFlowers(test, n);
        System.out.println(b);
    }
}
